Código fuente de 'Elimina valores duplicados.asp'

<html>

<head>
<title>Elimina valores duplicados - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
</head>

<p align="center"><b><font size="3">Elimina valores duplicados</font></b>
<body style="font-family: Arial; font-size: 11pt"></p>

<%
'Code Snippet for extracting unique values from an array.
'By B.Ravi Shankar(Tata Energy Research Insitiute)
dim aValues(6)
dim retvalues()

aValues(0) = "11"
aValues(1) = "22"
aValues(2) = "33"
aValues(3) = "33"
aValues(4) = "44"
aValues(5) = "55"
aValues(6) = "55"

redim preserve retvalues(1)
retvalues(0)=aValues(0)

  For I=0 to (UBound(aValues)-1)

		dim result
		result=0
		
		For y=0 to (ubound(retvalues)-1)
		result=StrComp(aValues(I),retvalues(y),1)

if (result=0) then 
exit for
end if

		Next

  		if(result<>0)then
			redim preserve retvalues(ubound(retvalues)+1)
			retvalues(ubound(retvalues)-1)=aValues(I)
     	end if


  Next
	
Response.write "<b>Este es el vector: </b><br>"

for n=lbound(avalues) to ubound(avalues)
	response.write avalues(n)
	if n<ubound(avalues) then response.write ","
next

Response.write "<br><br><b>Y este es el vector eliminando los valores duplicados: </b><br>"

   For x=0 to UBound(retvalues)
   Response.write retvalues(x)
	if x<ubound(avalues)-2 then Response.write ","
   Next

%>

</body>
</html>